<div class="card">
  <div class="card-header">
    <h4 class="card-title">
      应用(id=${appId!})实例列表
    </h4>
  </div>

  <div class="card-body">
    <div class="row">
      <h4 class="card-title">
        <i class="bi bi-globe"></i>实例列表
      </h4>
    </div>
    <div class="table-responsive">
      <table class="table table-striped table-bordered table-hover" id="tableDataList">
        <thead>
        <tr>
          <th>ID</th>
          <th>服务器ip:port</th>
          <th>实例内存使用</th>
          <th>角色</th>
          <th>实例所在机器可用内存</th>
          <th>对象数</th>
          <th>slot分布</th>
        </tr>
        </thead>
        <tbody>
        <#list instanceList as instance>
          <tr>
            <td><a href="${request.contextPath}/admin/instance/index?instanceId=${instance.id!}"
                   target="_blank">${instance.id!}</a></td>
            <td>${instance.ip!}:${instance.port!}</td>
            <td>
              <#assign instanceStatsMapKey = (instance.ip + ":" + instance.port)>
              <div class="progress progress-fs-1">
                <#if instanceStatsMap?? && (instanceStatsMap[instanceStatsMapKey])?? && (instanceStatsMap[instanceStatsMapKey]).memUsePercent??>
                  <#if ((instanceStatsMap[instanceStatsMapKey]).memUsePercent >= 80)>
                    <#assign progressBarStatus = "bg-danger">
                  <#else>
                    <#assign progressBarStatus = "bg-success">
                  </#if>
                  <#assign ariaValuenow = (instanceStatsMap[instanceStatsMapKey]).memUsePercent>
                <#else>
                  <#assign ariaValuenow = 0>
                  <#assign progressBarStatus = "bg-success">
                </#if>
                <div class="progress-bar ${progressBarStatus!}" role="progressbar"
                     aria-valuenow="${ariaValuenow!}"
                     aria-valuemax="100"
                     aria-valuemin="0"
                     style="width: ${ariaValuenow!}%; overflow: visible;">
                  <span style="color: #000000; margin-bottom: 0">
                    <#if instanceStatsMap?? && (instanceStatsMap[instanceStatsMapKey])??>
                      <#if (instanceStatsMap[instanceStatsMapKey]).usedMemory??>
                        <#assign userMemoryValue = ((instanceStatsMap[instanceStatsMapKey]).usedMemory / 1024 / 1024 / 1024)>
                      <#else>
                        <#assign userMemoryValue = 0>
                      </#if>
                      <#if (instanceStatsMap[instanceStatsMapKey]).maxMemory??>
                        <#assign maxMemoryValue = ((instanceStatsMap[instanceStatsMapKey]).maxMemory / 1024 / 1024 / 1024)>
                      <#else>
                        <#assign maxMemoryValue = 0>
                      </#if>
                    <#else>
                      <#assign userMemoryValue = 0>
                      <#assign maxMemoryValue = 0>
                    </#if>

                    ${userMemoryValue?string("0.00")}
                    G&nbsp;&nbsp;Used
                    /${maxMemoryValue?string("0.00")}G&nbsp;&nbsp;Total
                  </span>
                </div>
              </div>
            </td>
            <td>${instance.roleDesc!}</td>
            <td>
              <#if machineCanUseMem?? && machineCanUseMem[instance.ip]??>
                ${((machineCanUseMem[instance.ip])/1024/1024/1024)?string("0.00")}
              </#if>
            </td>
            <td>
              <#if instanceStatsMap?? && instanceStatsMap[instanceStatsMapKey]??>
                ${instanceStatsMap[instanceStatsMapKey].currItems!}
              </#if>
            </td>
            <td>
              <#if clusterSlotsMap?? && clusterSlotsMap[instanceStatsMapKey]??>
                <#assign index = 0>
                <#if clusterSlotsMap[instanceStatsMapKey].slotDistributeList??>
                  <#list clusterSlotsMap[instanceStatsMapKey].slotDistributeList as slotDistribute>
                    <#if index != 0>,</#if>
                    ${slotDistribute?trim}
                    <#assign index = index+1>
                  </#list>
                </#if>
              </#if>
            </td>
          </tr>
        </#list>
        </tbody>
      </table>
      <br/>
    </div>
    <div class="table-responsive">
      <table class="table table-striped table-bordered table-hover">
        <tbody>
        <tr>
          <td>申请人：</td>
          <td>${appAudit.userName!}</td>
          <td>appId:</td>
          <td>${appAudit.appId!}</td>
        </tr>
        <tr>
          <td>申请原因：</td>
          <td>${appAudit.info!}</td>
          <td>申请时间：</td>
          <td>${appAudit.createTime?string("yyyy-MM-dd HH:mm:ss")}</td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>